package com.timoon.manager.panel;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;

import com.googlecode.wicket.jquery.ui.JQueryBehavior;
import com.timoon.component.panel.jlayout.JLayouterPanel;
import com.timoon.manager.auth.BaseAuthPanel;
import com.timoon.manager.panel.passage.PassageCategoryPanel;
import com.timoon.manager.panel.product.ProductCommentsPanel;
import com.timoon.manager.panel.product.ProductGridPanel;
import com.timoon.manager.panel.product.ProductSortPanel;
import com.timoon.manager.panel.product.ProductTypePanel;

public class MenuPanel extends BaseAuthPanel {

	public MenuPanel(String id) {
		super(id);
		// TODO Auto-generated constructor stub
		
		renderPanel();
	}

	private void renderPanel() {
		// TODO Auto-generated method stub
		
		add(new JQueryBehavior("#accordion", "accordion"));
		
		renderProduct();
	}

	private void renderProduct() {
		// TODO Auto-generated method stub
		
		renderAllProduct();
		
		renderProductComment();
		
		renderProductSort();
		
		renderProductType();
		
		renderPassageCategroy();//新闻种类
		
	}

	private void renderPassageCategroy() {
		// TODO Auto-generated method stub
		AjaxLink link=new AjaxLink("wk_news_category") {

			@Override
			public void onClick(AjaxRequestTarget arg0) {
				// TODO Auto-generated method stub
				JLayouterPanel layouter=(JLayouterPanel) this.getSession().getAttribute("layouter");
				
				layouter.updatePanel(JLayouterPanel.CENTER_PANEL, new PassageCategoryPanel(JLayouterPanel.CENTER_PANEL), arg0);
			}
		};
		add(link);
	}

	private void renderProductType() {
		// TODO Auto-generated method stub
		AjaxLink link=new AjaxLink("wk_product_type") {

			@Override
			public void onClick(AjaxRequestTarget arg0) {
				// TODO Auto-generated method stub
				JLayouterPanel layouter=(JLayouterPanel) this.getSession().getAttribute("layouter");
				
				layouter.updatePanel(JLayouterPanel.CENTER_PANEL, new ProductTypePanel(JLayouterPanel.CENTER_PANEL,null), arg0);
			}
		};
		add(link);
	}

	private void renderProductSort() {
		// TODO Auto-generated method stub
		
		AjaxLink link=new AjaxLink("wk_product_sort") {

			@Override
			public void onClick(AjaxRequestTarget arg0) {
				// TODO Auto-generated method stub
				JLayouterPanel layouter=(JLayouterPanel) this.getSession().getAttribute("layouter");
				
				layouter.updatePanel(JLayouterPanel.CENTER_PANEL, new ProductSortPanel(JLayouterPanel.CENTER_PANEL), arg0);
			}
		};
		add(link);
		
	}

	private void renderProductComment() {
		// TODO Auto-generated method stub
		AjaxLink link=new AjaxLink("wk_product_all") {

			@Override
			public void onClick(AjaxRequestTarget arg0) {
				// TODO Auto-generated method stub
				JLayouterPanel layouter=(JLayouterPanel) this.getSession().getAttribute("layouter");
				
				layouter.updatePanel(JLayouterPanel.CENTER_PANEL, new ProductGridPanel(JLayouterPanel.CENTER_PANEL), arg0);
			}
		};
		add(link);
	}

	private void renderAllProduct() {
		// TODO Auto-generated method stub
		
		AjaxLink link=new AjaxLink("wk_product_comment") {

			@Override
			public void onClick(AjaxRequestTarget arg0) {
				// TODO Auto-generated method stub
				JLayouterPanel layouter=(JLayouterPanel) this.getSession().getAttribute("layouter");
				
				layouter.updatePanel(JLayouterPanel.CENTER_PANEL, new ProductCommentsPanel(JLayouterPanel.CENTER_PANEL), arg0);
			}
		};
		add(link);
	}

}
